package com.bhs.sansonglogistics.ui.order;

import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.utils.StatusBarUtil;
import com.bhs.sansonglogistics.utils.ToastUtil;
import com.bhs.sansonglogistics.view.LinePathView;

import java.io.IOException;

/**
 * 电子签名
 */
public class ElectronicSignatureActivity extends AppCompatActivity implements View.OnClickListener {

    private LinePathView mLinePathView;
    private Button mBtnConfirm;
    private Button mBtnClear;
    private String path;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_electronic_signature);
        //设置状态栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        initView();
    }

    private void initView() {
        mLinePathView = findViewById(R.id.linePathView);
        findViewById(R.id.fl_back).setOnClickListener(this);
        mBtnConfirm = findViewById(R.id.btn_confirm);
        mBtnConfirm.setOnClickListener(this);
        mBtnClear = findViewById(R.id.btn_clear);
        mBtnClear.setOnClickListener(this);
        path=getIntent().getStringExtra("path");
    }

    @Override
    public void onClick(View view) {
        if(view.getId()==R.id.btn_confirm){
            try {
                mLinePathView.save(path);
                finish();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }else if(view.getId()==R.id.btn_clear){
            mLinePathView.clear();
        }else {
            finish();
        }
    }
}